// this file was added from scratch to the project by Josh Latvatalo
#include "Order.h"
#include <string>
#include <fstream>
using namespace std;



// constructors
Order::Order (int ord_id, int serv_id, int tab_id,int year, int month, int day, int hour, int minute) {
	order_id = ord_id;
	server_id = serv_id;
	table_id = tab_id;
	order_date= Date::Date(year, month, day);
	order_time= Time::Time(hour,minute);
}

// utility functions
void Order::display(){
	cout<< "The order id was " << order_id;
	cout<< "The server id was " << server_id;
	cout<< "The table id was " << table_id;
	cout<< "The date was " << order_date.display_date();
	cout<< "The time was " << order_time.display_time();
}

int Order::get_order_id(){//JTL B2.a
	return order_id;
}

int Order::get_server_id(){//JTL B2.a
	return server_id;
}

int Order::get_table_id(){//JTL B2.a
	return table_id;
}


void read_order(vector<Order>& orders, string file)
{
	ifstream file_in;
	file_in.open(file.c_str());
	if(file_in.fail())
	{
		cerr<<"\n ERROR, unable to open file\n";
	}
	else{
		int num_of_reads;
		file_in>>num_of_reads;
		int count =0;
		while(count<num_of_reads)
		{
			int ord,serv,tab,y,m,d,h,min;
			file_in >> ord >> serv >> tab >> y >> m >> d >> h >> min;
			orders.push_back(Order(ord,serv,tab,y,m,d,h,min));
			count++;
		}
	}
}


